package com.example.mybaties.testone.service;

import com.example.mybaties.testone.domain.SysDict;
import com.example.mybaties.testone.mapper.SysDictMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysDictServiceImpl implements SysDictService {

    @Resource
    private SysDictMapper sysDictMapper;

    @Override
    public boolean saveOrUpdate(SysDict sysDict) {
        int tmp;
        if (sysDict.getId() == null) {
            tmp = sysDictMapper.insert(sysDict);
        } else {
            tmp = sysDictMapper.update(sysDict);
        }
        return tmp == 1;
    }

    @Override
    public boolean deleteById(Long id) {
        return sysDictMapper.deleteById(id) == 1;
    }

    @Override
    public SysDict selectSysDictById(Long id) {
        return sysDictMapper.selectSysDictById(id);
    }

    @Override
    public List<SysDict> selectAll() {
        return sysDictMapper.selectAll();
    }

    public void setSysDictMapper(SysDictMapper sysDictMapper) {
        this.sysDictMapper = sysDictMapper;
    }
}
